package com.tma.internship.ClassesInfo;

import java.util.List;
import com.tma.internship.activities.R;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class BookmarkAdapter extends ArrayAdapter<CommentInfo> {
	private int resId;
	public BookmarkAdapter(Context context, int textViewResourceId, List<CommentInfo> objects) {
		super(context, textViewResourceId, objects);
		// TODO Auto-generated constructor stub
		this.resId = textViewResourceId;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if (convertView == null){
			LayoutInflater inflater = ((Activity) getContext()).getLayoutInflater();
			convertView = inflater.inflate(resId, null);
		}
		CommentInfo current = getItem(position);
		TextView bookName = (TextView) convertView.findViewById(R.id.bookmark_name);
		TextView bookTime = (TextView) convertView.findViewById(R.id.bookmark_time);
		TextView bookPage = (TextView) convertView.findViewById(R.id.bookmark_page);
		TextView bookCmt = (TextView) convertView.findViewById(R.id.bookmark_cmt);
		bookName.setText(getContext().getString(R.string.ebook)+" "+current.getBookName());
		bookTime.setText(getContext().getString(R.string.time)+" "+current.getTime());
		bookPage.setText(getContext().getString(R.string.page)+" "+current.getPage());
		bookCmt.setText(getContext().getString(R.string.cmt)+" "+current.getCmt());
		return convertView;
	}
	
}
